package usaco;
/*
ID: toregg1
LANG: JAVA
TASK: cript1
 */

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

public class cript1 {
	static Map<Integer, Integer> map = new HashMap<Integer, Integer>();
	static Map<Integer, Integer> map_prime = new HashMap<Integer, Integer>(){
			{
				put(2, 2);
				put(3, 3);
				put(5, 5);
				put(7, 7);
			} 
	};
	static int[] primes = new int[]{2, 3, 5, 7};
		
		
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new FileReader("usaco/cript1.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("usaco/out")));
		
		String line;
		int num = Integer.parseInt(in.readLine());
		int[] digitStrings = new int[num];
		line = in.readLine();
		for (int i = 0; i < num; i++) {
			digitStrings[i] = Integer.parseInt(line.split(" ")[i]);
		}
		
		for (int i = 0; i < digitStrings.length; i++) {
			map.put(digitStrings[i], digitStrings[i]);
		}
		
		int[] digit_3 = pp(digitStrings, 3);
		int[] digit_2 = pp(digitStrings, 2);
		
		int max = 0;
		int product = 0;
		int partProduct_1;
		int partProduct_2;
		
		for (int i = 0; i < digit_2.length; i++) {
			for (int j = 0; j < digit_3.length; j++) {
				/*if(!isContainPrime(digit_2[i]) || !isContainPrime(digit_3[j])){
					continue;
				}*/
				product = digit_2[i] * digit_3[j];
				partProduct_1 = (digit_2[i] % 10) * digit_3[j];
				partProduct_2 = (digit_2[i] / 10) * digit_3[j];
				if(partProduct_1 > 1000 || partProduct_2 > 1000){
					continue;
				}
				if (product < 10000 && !isContainOtherDigit(digitStrings, partProduct_1) && 
						!isContainOtherDigit(digitStrings, partProduct_2) && !isContainOtherDigit(digitStrings, product)) {
					max++;
					System.out.println(partProduct_1 + " " + partProduct_2);
					System.out.println(digit_2[i] + " * " + digit_3[j] + " = " + product);
				}
				
			}
		}
		
		//System.out.println(isContainPrime(63489));
		System.out.println(max);
		out.println(max);
		out.close();
		System.exit(0);
	}
	
	private static boolean isContainPrime(int n){
		boolean flag = false;
		String num = String.valueOf(n);
		for (int i = 0; i < num.length(); i++) {
			if(map_prime.get(Integer.parseInt(num.charAt(i) + "")) != null){
				return true;
			}
		}
		return false;
	}
	
	private static boolean isContainOtherDigit(int[] digits, int n){
		boolean flag = false;
		String num = String.valueOf(n);
		for(int k = 0; k < num.length(); k++){
			if(map.get(Integer.parseInt(num.charAt(k)+"")) == null){
				return true;
			}
		}
		return flag;
	}
	
	private static int[] pp(int[] a, int n){
		int nums = (int) Math.pow(a.length, n);
		int[] rst = new int[nums];
		int j;
		for(int i = 0; i < nums * n; i++){
			if(i < nums){
				rst[i] = a[i % a.length];
			}else{
				j = i / nums;
				rst[i % nums] = Integer.parseInt(String.valueOf(rst[i % nums]) + String.valueOf(a[((i - nums * j) / (int)Math.pow(a.length, n - j)) % a.length]));
			}
		}
		return rst;
	}
}
